// var i;
// var AL_GAME_HUA_AddPrefab = require("./AL_GAME_HUA_AddPrefab");
// var AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
// var AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_EventConfig = require("./AL_GAME_HUA_EventConfig");
// var AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
// var AL_GAME_HUA_PropConfig = require("./AL_GAME_HUA_PropConfig");
// var AL_GAME_HUA_ShopConfig = require("./AL_GAME_HUA_ShopConfig");
// var AL_GAME_HUA_CurrencyData = require("./AL_GAME_HUA_CurrencyData");
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var AL_GAME_HUA_GameBase = require("./AL_GAME_HUA_GameBase");
// var AL_GAME_HUA_GamePool = require("./AL_GAME_HUA_GamePool");
// var AL_GAME_HUA_PropButton = require("./AL_GAME_HUA_PropButton");
// var AL_GAME_HUA_MissionConfig = require("./AL_GAME_HUA_MissionConfig");
// var AL_GAME_HUA_GoodsConfig = require("./AL_GAME_HUA_GoodsConfig");
// var AL_GAME_HUA_ShopData = require("./AL_GAME_HUA_ShopData");
// var AL_GAME_HUA_ToggleCustom = require("./AL_GAME_HUA_ToggleCustom");
// var I = cc._decorator;
// var S = I.ccclass;
// var w = I.property;
// var Y = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.bg = null;
//         t.spriteframe_bg_list = [];
//         t.label_star = null;
//         t.starIcon = null;
//         t.starx2 = null;
//         t.label_time = null;
//         t.timeIcon = null;
//         t.comboNode = null;
//         t.comboProgressBar = null;
//         t.comboLabel = null;
//         t.levelLabel = null;
//         t.levelProgressBar = null;
//         t.topNode = null;
//         t.bottomNode = null;
//         t.propButtons = [];
//         t.enterPropLayout = null;
//         t.timeWarnNode = null;
//         t.winSkes = [];
//         t.challengeNode = null;
//         t.completeSp = null;
//         t.specialFlag = null;
//         t.iceNode = null;
//         t.themeToggle = null;
//         t.starNum = 0;
//         t.popNum = 0;
//         t.isTimeWarning = !1;
//         t.isTimeWarning2 = !1;
//         t.isTimeWarning3 = !1;
//         t.comboTween = null;
//         t.comboCount = 0;
//         t._tm = Number.MAX_SAFE_INTEGER;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onLoad = function () {
//         AL_APP_SDK_MANAGER.on(AL_GAME_HUA_Define.GameEvent.CHANGE_SHOP_USE, this.shuaxin_beijing, this);
//     };
//     t.prototype.onDestroy = function () {
//         AL_APP_SDK_MANAGER.off(this);
//     };
//     t.prototype.onPreload = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             return __generator(this, function (e) {
//                 switch (e.label) {
//                     case 0:
//                         console.log("******shuaxin_beijing");
//                         return [4, this.shuaxin_beijing()];
//                     case 1:
//                         e.sent();
//                         console.log("******chushihua_ui");
//                         this.chushihua_ui();
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.onPrepare = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             return __generator(this, function (e) {
//                 switch (e.label) {
//                     case 0:
//                         return AL_GAME_HUA_Instance.Instance.LevelType != AL_GAME_HUA_Define.Define.LevelType.NORMAL
//                             ? [3, 2]
//                             : [4, this.jiancha_shiyong_xin_pifu()];
//                     case 1:
//                         e.sent();
//                         e.label = 2;
//                     case 2:
//                         return [4, this.bofang_jinru_donghua()];
//                     case 3:
//                         e.sent();
//                         return [4, this.xianshi_tiaozhan_guanqia_donghua()];
//                     case 4:
//                         e.sent();
//                         return [4, this.xianshi_jinru_prop_donghua()];
//                     case 5:
//                         e.sent();
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.chuli_youxi_kaishi = function () {
//         this.propButtons.forEach(function (e) {
//             e.shezhi_anniu_shifou_youxiao(!0);
//             ailin_sdk_manager.yincangBannerGuanggao();
//         });
//     };
//     t.prototype.chuli_youxi_zhanting = function () {
//         this.propButtons.forEach(function (e) {
//             e.chuli_youxi_zhanting();
//         });
//         cc.director.getActionManager().pauseTargets([this.comboProgressBar]);
//     };
//     t.prototype.chuli_youxi_jixu = function () {
//         this.propButtons.forEach(function (e) {
//             e.chuli_youxi_jixu();
//         });
//         if (!AL_GAME_HUA_Instance.Instance.Game.isTimePause) {
//             cc.director.getActionManager().resumeTargets([this.comboProgressBar]);
//         }
//     };
//     t.prototype.chuli_youxi_shengli = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             return __generator(this, function (e) {
//                 switch (e.label) {
//                     case 0:
//                         AL_GAME_HUA_Common.Common.bofang_yinxiao("complete", this);
//                         return [4, this.bofang_shengli_donghua()];
//                     case 1:
//                         e.sent();
//                         this.bofang_tuichu_donghua();
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.chuli_youxi_shibai = function () {};
//     t.prototype.chuli_youxi_tuichu = function () {};
//     t.prototype.onUpdate = function () {};
//     t.prototype.chushihua_ui = function () {
//         var e = this;
//         var t = AL_GAME_HUA_GameData.GameData.getInstance();
//         this.starNum = 0;
//         this.shuaxin_xingxing();
//         var n = AL_GAME_HUA_GameData.GameData.getInstance().gameTheme;
//         this.themeToggle.isChecked = 0 == n;
//         this.shuaxin_zhuti();
//         AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL
//             ? (this.levelLabel.string = "Lv:" + t.huoqu_yijiesuo_guanqia().toString())
//             : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE
//             ? (this.levelLabel.string = "Lv:" + AL_GAME_HUA_Instance.Instance.ChallengeLevel.toString())
//             : AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL &&
//               (this.levelLabel.string = "LV:" + t.huoqu_yijiesuo_teshu_guanqia().toString());
//         this.levelProgressBar.progress = 0;
//         this.comboProgressBar.progress = 0;
//         this.comboNode.active = !1;
//         this.enterPropLayout.active = !1;
//         this.timeWarnNode.active = !1;
//         this.challengeNode.active = !1;
//         this.completeSp.node.active = !1;
//         this.specialFlag.active = AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL;
//         if (AL_GAME_HUA_Common.Common.shifou_keyi_kaiqi_tiaozhan_guanqia()) {
//             t.huoqu_prop_jiesuo(AL_GAME_HUA_PropConfig.PropId.REFRESH_GAME) &&
//             0 == t.huoqu_prop_shuliang(AL_GAME_HUA_PropConfig.PropId.REFRESH_GAME)
//                 ? t.genggai_prop_shuliang(AL_GAME_HUA_PropConfig.PropId.REFRESH_GAME, 1)
//                 : t.huoqu_prop_jiesuo(AL_GAME_HUA_PropConfig.PropId.TIPS_GAME) &&
//                   0 == t.huoqu_prop_shuliang(AL_GAME_HUA_PropConfig.PropId.TIPS_GAME) &&
//                   t.genggai_prop_shuliang(AL_GAME_HUA_PropConfig.PropId.TIPS_GAME, 1);
//         }
//         var o = [0.5, 0.5, 0.5, AL_GAME_HUA_GameConst.GameConst.getInstance().time_prop_duration];
//         this.propButtons.forEach(function (t, n) {
//             t.init({
//                 cd: o[n],
//                 handle_event_click: function () {
//                     t.type == AL_GAME_HUA_PropConfig.PropId.TIME_GAME
//                         ? (e.handle_event_click_button_time(),
//                           AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                               AL_GAME_HUA_MissionConfig.MissionType.PROP6
//                           ))
//                         : t.type == AL_GAME_HUA_PropConfig.PropId.CHANGE_GAME
//                         ? (e.handle_event_click_button_change(),
//                           AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                               AL_GAME_HUA_MissionConfig.MissionType.PROP5
//                           ))
//                         : t.type == AL_GAME_HUA_PropConfig.PropId.REFRESH_GAME
//                         ? (e.handle_event_click_button_refresh(),
//                           AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                               AL_GAME_HUA_MissionConfig.MissionType.PROP4
//                           ))
//                         : t.type == AL_GAME_HUA_PropConfig.PropId.TIPS_GAME &&
//                           (e.handle_event_click_button_tips(),
//                           AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                               AL_GAME_HUA_MissionConfig.MissionType.PROP3
//                           ));
//                 }
//             });
//             t.shezhi_anniu_shifou_youxiao(!1);
//         });
//     };
//     t.prototype.shuaxin_zhuti = function () {
//         var e = AL_GAME_HUA_GameData.GameData.getInstance().gameTheme;
//         this.bg.spriteFrame = this.spriteframe_bg_list[e];
//     };
//     t.prototype.xianshi_tiaozhan_guanqia_donghua = function () {
//         var e = this;
//         return new Promise(function (t) {
//             if (
//                 (AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE &&
//                     2 == AL_GAME_HUA_Instance.Instance.ChallengeLevel) ||
//                 (AL_GAME_HUA_Common.Common.shifou_keyi_kaiqi_tiaozhan_guanqia() &&
//                     AL_GAME_HUA_GameConst.GameConst.getInstance().showHardTitle)
//             ) {
//                 e.challengeNode.active = !0;
//                 var n = e.challengeNode.getChildByName("ui_nandubiaosheng").getComponent(sp.Skeleton);
//                 n.setSkin("zh" == AL_APP_SDK_MANAGER.languageManager.getLanguage() ? "zh" : "zh");
//                 var o = n.setAnimation(0, "01-start", !1);
//                 n.setTrackCompleteListener(o, function () {
//                     t();
//                 });
//             } else {
//                 t();
//             }
//         });
//     };
//     t.prototype.xianshi_wancheng_donghua = function () {
//         var e = this;
//         return new Promise(function (t) {
//             e.completeSp.node.active = !0;
//             var n = e.completeSp.setAnimation(0, "01-appear", !1);
//             e.completeSp.setTrackCompleteListener(n, function () {
//                 e.scheduleOnce(function () {
//                     t();
//                 }, 0.5);
//             });
//         });
//     };
//     t.prototype.bofang_jinru_donghua = function () {
//         var e = this;
//         return new Promise(function (t) {
//             var n = Math.min(1, cc.winSize.width / cc.view.getDesignResolutionSize().width);
//             cc.tween(e.topNode)
//                 .to(
//                     0.28,
//                     {
//                         y: cc.winSize.height / 2 / n
//                     },
//                     {
//                         easing: "sineOut"
//                     }
//                 )
//                 .start();
//             cc.tween(e.bottomNode)
//                 .to(
//                     0.28,
//                     {
//                         y:
//                             (-cc.winSize.height / 2 +
//                                 AL_GAME_HUA_Define.Define.Margin.bottom -
//                                 e.bottomNode.height / 2) /
//                             n
//                     },
//                     {
//                         easing: "sineOut"
//                     }
//                 )
//                 .call(function () {
//                     t();
//                 })
//                 .start();
//         });
//     };
//     t.prototype.bofang_tuichu_donghua = function () {
//         var e = this;
//         return new Promise(function (t) {
//             var n = Math.min(1, cc.winSize.width / cc.view.getDesignResolutionSize().width);
//             cc.tween(e.topNode)
//                 .to(
//                     0.28,
//                     {
//                         y: (cc.winSize.height / 2 + e.topNode.height / 2) / n
//                     },
//                     {
//                         easing: "sineOut"
//                     }
//                 )
//                 .start();
//             cc.tween(e.bottomNode)
//                 .to(
//                     0.28,
//                     {
//                         y: (-cc.winSize.height / 2 - e.bottomNode.height / 2) / n
//                     },
//                     {
//                         easing: "sineOut"
//                     }
//                 )
//                 .call(function () {
//                     t();
//                 })
//                 .start();
//         });
//     };
//     t.prototype.bofang_shengli_donghua = function () {
//         this.winSkes.forEach(function (e) {
//             e.zIndex = 1e3;
//             e.active = !0;
//         });
//         return AL_GAME_HUA_Common.Common.delay(0.67);
//     };
//     t.prototype.jiancha_shiyong_xin_pifu = function () {
//         return AL_GAME_HUA_GameConst.GameConst.getInstance().skin_enabled
//             ? new Promise(function (e) {
//                   var t = AL_GAME_HUA_ShopData.ShopData.getInstance();
//                   if (
//                       AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() >
//                       AL_GAME_HUA_GameConst.GameConst.getInstance().pop_try_skin
//                   ) {
//                       if (
//                           t.trySkinCount > 0 &&
//                           t.trySkinCount % AL_GAME_HUA_GameConst.GameConst.getInstance().pop_try_skin_count == 0
//                       ) {
//                           var n = AL_GAME_HUA_ShopConfig.ShopConfig.getInstance().huoqu_suoyou_de_peizhi();
//                           var o = [];
//                           n.forEach(function (e, n) {
//                               if (0 == t.huoqu_shangdian_shifou_yi_jiesuo(n)) {
//                                   o.push(n);
//                               }
//                           });
//                           if (o.length > 0) {
//                               var i = o.huoqu_shuzu_zhong_suiji_yige_yuansu();
//                               AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_changshi_pifu_mianban({
//                                   skin: i,
//                                   onClose: function () {
//                                       e();
//                                   }
//                               });
//                               return void t.trySkinCount++;
//                           }
//                       }
//                       t.trySkinCount++;
//                   }
//                   e();
//               })
//             : Promise.resolve();
//     };
//     t.prototype.shuaxin_guanqia_jindu = function (e) {
//         this.levelProgressBar.progress = e;
//     };
//     t.prototype.xianshi_jinru_prop_donghua = function () {
//         return __awaiter(this, void 0, void 0, function () {
//             var e;
//             var t;
//             var n;
//             var o;
//             var i;
//             return __generator(this, function (r) {
//                 switch (r.label) {
//                     case 0:
//                         this.enterPropLayout.active = !0;
//                         e = AL_GAME_HUA_GameData.GameData.getInstance();
//                         t = [];
//                         n = this.enterPropLayout.getChildByName("timeprop");
//                         o = this.enterPropLayout.getChildByName("magicprop");
//                         i = this.enterPropLayout.getChildByName("starprop");
//                         if (e.useTimeEnter) {
//                             t.push(this.jinru_xianshi_donghua(n));
//                         }
//                         n.active = e.useTimeEnter;
//                         if (e.useStarEnter) {
//                             t.push(this.jinru_xianshi_donghua(i));
//                         }
//                         i.active = e.useStarEnter;
//                         if (e.useTipsEnter) {
//                             t.push(this.jinru_xianshi_donghua(o));
//                         }
//                         o.active = e.useTipsEnter;
//                         this.enterPropLayout.getComponent(cc.Layout).updateLayout();
//                         this.enterPropLayout.getComponent(cc.Layout).enabled = !1;
//                         return [4, Promise.all(t)];
//                     case 1:
//                         r.sent();
//                         return e.useTimeEnter
//                             ? (AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                                   AL_GAME_HUA_MissionConfig.MissionType.PROP1
//                               ),
//                               [4, this.donghua_prop_1(n)])
//                             : [3, 3];
//                     case 2:
//                         r.sent();
//                         e.useTimeEnter = !1;
//                         r.label = 3;
//                     case 3:
//                         return e.useStarEnter
//                             ? (AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                                   AL_GAME_HUA_MissionConfig.MissionType.PROP2
//                               ),
//                               [4, this.donghua_prop_2(i)])
//                             : [3, 5];
//                     case 4:
//                         r.sent();
//                         e.useStarEnter = !1;
//                         r.label = 5;
//                     case 5:
//                         return e.useTipsEnter
//                             ? (AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
//                                   AL_GAME_HUA_MissionConfig.MissionType.PROP0
//                               ),
//                               [4, this.donghua_prop_0(o)])
//                             : [3, 7];
//                     case 6:
//                         r.sent();
//                         e.useTipsEnter = !1;
//                         r.label = 7;
//                     case 7:
//                         this.enterPropLayout.active = !1;
//                         return [2];
//                 }
//             });
//         });
//     };
//     t.prototype.donghua_prop_0 = function (e) {
//         return __awaiter(this, void 0, void 0, function () {
//             var t = this;
//             return __generator(this, function () {
//                 return [
//                     2,
//                     new Promise(function (n) {
//                         var o = e.children[0].getComponent(sp.Skeleton);
//                         o.setAnimation(0, "idle", !0);
//                         AL_GAME_HUA_Common.Common.bofang_yinxiao("mofabang", t);
//                         o.scheduleOnce(function () {
//                             return __awaiter(t, void 0, void 0, function () {
//                                 var t;
//                                 return __generator(this, function (o) {
//                                     switch (o.label) {
//                                         case 0:
//                                             t = 0;
//                                             o.label = 1;
//                                         case 1:
//                                             return t < 4
//                                                 ? [4, AL_GAME_HUA_Instance.Instance.Game.stage.chuli_tishi_luoji()]
//                                                 : [3, 4];
//                                         case 2:
//                                             o.sent();
//                                             o.label = 3;
//                                         case 3:
//                                             t++;
//                                             return [3, 1];
//                                         case 4:
//                                             cc.tween(e)
//                                                 .to(0.25, {
//                                                     scale: 0,
//                                                     opacity: 0
//                                                 })
//                                                 .call(function () {
//                                                     e.destroy();
//                                                 })
//                                                 .start();
//                                             n();
//                                             return [2];
//                                     }
//                                 });
//                             });
//                         }, 0.5);
//                     })
//                 ];
//             });
//         });
//     };
//     t.prototype.donghua_prop_1 = function (e) {
//         var t = this;
//         return new Promise(function (n) {
//             var o = e.getPosition();
//             var i = t.timeIcon.convertToWorldSpaceAR(cc.v2(0, 0));
//             var r = e.parent.convertToNodeSpaceAR(i);
//             var a = Math.get_random(-200, 200);
//             var s = cc.v2((o.x + r.x) / 2 + a, (o.y + r.y) / 2);
//             cc.tween(e)
//                 .to(1, {
//                     scale: 0.5
//                 })
//                 .start();
//             cc.tween(e)
//                 .bezierTo(2 / 3, s, s, r)
//                 .call(function () {
//                     t.chuangjian_prop_texiao(t.timeIcon);
//                     AL_GAME_HUA_Instance.Instance.Game.totalTime += 60;
//                     t.shuaxin_shijian(AL_GAME_HUA_Instance.Instance.Game.totalTime);
//                     e.destroy();
//                     AL_GAME_HUA_Common.Common.bofang_yinxiao("Progress", t);
//                     n();
//                 })
//                 .start();
//         });
//     };
//     t.prototype.donghua_prop_2 = function (e) {
//         var t = this;
//         return new Promise(function (n) {
//             var o = e.getPosition();
//             var i = t.starIcon.convertToWorldSpaceAR(cc.v2(0, 0));
//             var r = e.parent.convertToNodeSpaceAR(i);
//             var a = Math.get_random(-200, 200);
//             var s = cc.v2((o.x + r.x) / 2 + a, (o.y + r.y) / 2);
//             cc.tween(e)
//                 .to(1, {
//                     scale: 0.5
//                 })
//                 .start();
//             cc.tween(e)
//                 .bezierTo(2 / 3, s, s, r)
//                 .call(function () {
//                     t.starIcon.opacity = 0;
//                     t.starx2.active = !0;
//                     t.chuangjian_prop_texiao(t.starIcon);
//                     AL_GAME_HUA_Common.Common.bofang_yinxiao("Progress", t);
//                     e.destroy();
//                     n();
//                 })
//                 .start();
//         });
//     };
//     t.prototype.chuangjian_prop_texiao = function (e) {
//         var t = AL_GAME_HUA_GamePool.GamePool.Instance.get("crashEffect");
//         t.parent = e;
//         var n = t.children[0].getComponent(sp.Skeleton);
//         var o = n.setAnimation(0, "show", !1);
//         n.setTrackCompleteListener(o, function () {
//             AL_GAME_HUA_GamePool.GamePool.Instance.put(t);
//         });
//         t.setPosition(cc.v2());
//         return t;
//     };
//     t.prototype.jinru_xianshi_donghua = function (e) {
//         return new Promise(function (t) {
//             e.active = !0;
//             e.scale = 0;
//             e.opacity = 0;
//             cc.tween(e)
//                 .to(
//                     0.2,
//                     {
//                         scale: 1,
//                         opacity: 255
//                     },
//                     {
//                         easing: "backOut"
//                     }
//                 )
//                 .call(function () {
//                     t();
//                 })
//                 .start();
//         });
//     };
//     t.prototype.shuaxin_xingxing = function () {
//         this.label_star.string = this.starNum.toString();
//     };
//     t.prototype.shuaxin_beijing = function () {
//         var e = this;
//         var t = AL_GAME_HUA_ShopData.ShopData.getInstance().huoqu_shangdian_shifou_zhengzai_shiyong();
//         return AL_GAME_HUA_ShopConfig.ShopConfig.getInstance()
//             .jiazai_beijing_pifu(t)
//             .then(function (t) {
//                 e.bg.spriteFrame = t;
//                 e.bg.addAutoReleaseAssets(t);
//             });
//     };
//     t.prototype.shuaxin_shijian = function (e) {
//         var t = Math.floor(e);
//         var n = t < AL_GAME_HUA_GameConst.GameConst.getInstance().warnning_time1;
//         if (this.isTimeWarning != n) {
//             this.isTimeWarning = n;
//             this.label_time.node.color = n ? cc.color().fromHEX("#F93206") : cc.color().fromHEX("#FFFFFF");
//             n
//                 ? (this.timeIcon.stopAllActions(),
//                   cc
//                       .tween(this.timeIcon)
//                       .to(0.3, {
//                           scale: 1.05
//                       })
//                       .to(0.3, {
//                           scale: 0.95
//                       })
//                       .union()
//                       .repeatForever()
//                       .start())
//                 : (this.timeIcon.stopAllActions(), (this.timeIcon.scale = 1));
//         }
//         var o = t < AL_GAME_HUA_GameConst.GameConst.getInstance().warnning_time2;
//         if (this.isTimeWarning2 != o) {
//             this.isTimeWarning2 = o;
//         }
//         var i = t < AL_GAME_HUA_GameConst.GameConst.getInstance().warnning_time3;
//         if (this.isTimeWarning3 != i) {
//             this.isTimeWarning3 = i;
//             i ? this.xianshi_shijian_jinggao() : this.yincang_shijian_jinggao();
//         }
//         if (i && this._tm != t) {
//             this._tm = t;
//             AL_GAME_HUA_Common.Common.bofang_yinxiao("timer", this);
//         }
//         var r = AL_GAME_HUA_Common.Common.geshihua_shijian(Math.max(0, 1e3 * e));
//         if (r != this.label_time.string) {
//             this.label_time.string = r;
//         }
//     };
//     t.prototype.xianshi_shijian_jinggao = function () {
//         this.timeWarnNode.active = !0;
//         this.timeWarnNode.opacity = 0;
//         this.timeWarnNode.stopAllActions();
//         cc.tween(this.timeWarnNode)
//             .to(0.3, {
//                 opacity: 255
//             })
//             .to(0.7, {
//                 opacity: 100
//             })
//             .union()
//             .repeatForever()
//             .start();
//     };
//     t.prototype.yincang_shijian_jinggao = function () {
//         var e = this;
//         this.timeWarnNode.stopAllActions();
//         cc.tween(this.timeWarnNode)
//             .to(1, {
//                 opacity: 0
//             })
//             .call(function () {
//                 e.timeWarnNode.active = !1;
//             })
//             .start();
//     };
//     t.prototype.handle_event_click_button_tips = function () {
//         AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
//             source: AL_GAME_HUA_EventConfig.AssetsSource.game,
//             action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
//             goodsList: [
//                 {
//                     goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_prompt,
//                     num: 1
//                 }
//             ]
//         });
//         AL_GAME_HUA_Instance.Instance.Game.stage.chuli_tishi_luoji();
//     };
//     t.prototype.handle_event_click_button_refresh = function () {
//         AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
//             source: AL_GAME_HUA_EventConfig.AssetsSource.game,
//             action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
//             goodsList: [
//                 {
//                     goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_reset,
//                     num: 1
//                 }
//             ]
//         });
//         AL_GAME_HUA_Instance.Instance.Game.stage.shuaxin_daoju_he_yuansu_zhuangtai();
//     };
//     t.prototype.handle_event_click_button_change = function () {
//         AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
//             source: AL_GAME_HUA_EventConfig.AssetsSource.game,
//             action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
//             goodsList: [
//                 {
//                     goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_brush,
//                     num: 1
//                 }
//             ]
//         });
//         AL_GAME_HUA_Instance.Instance.Game.stage.daoju_qihuan();
//     };
//     t.prototype.handle_event_click_button_time = function () {
//         AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
//             source: AL_GAME_HUA_EventConfig.AssetsSource.game,
//             action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
//             goodsList: [
//                 {
//                     goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_freeze,
//                     num: 1
//                 }
//             ]
//         });
//         AL_GAME_HUA_Instance.Instance.Game.stage.shijian_daoju_xiaoguo_luoji();
//     };
//     t.prototype.xianshi_combo = function (e) {
//         var t = this;
//         var n = ++this.comboCount;
//         this.comboNode.active = !0;
//         this.comboProgressBar.progress = 1;
//         this.comboLabel.string = n.toString();
//         if (this.comboTween) {
//             this.comboTween.stop();
//         }
//         var o = Math.max(3, 10 - 0.5 * n);
//         this.comboTween = cc
//             .tween(this.comboProgressBar)
//             .to(o, {
//                 progress: 0
//             })
//             .call(function () {
//                 t.comboNode.active = !1;
//                 t.comboProgressBar.progress = 0;
//                 t.comboCount = 0;
//                 t.comboTween = null;
//             })
//             .start();
//         if (AL_GAME_HUA_Instance.Instance.Game.isTimePause) {
//             this.zhanting_combo();
//         }
//         n >= 4
//             ? AL_GAME_HUA_Common.Common.bofang_yinxiao("stars05", this)
//             : AL_GAME_HUA_Common.Common.bofang_yinxiao("stars0" + n, this);
//         if (n >= 3) {
//             this.xianshi_word(n - 3, e);
//         }
//     };
//     t.prototype.zhanting_combo = function () {
//         cc.director.getActionManager().pauseTargets([this.comboProgressBar]);
//     };
//     t.prototype.jixu_combo = function () {
//         cc.director.getActionManager().resumeTargets([this.comboProgressBar]);
//     };
//     t.prototype.xianshi_word = function (e, t) {
//         var n = ["cool", "good", "pretty", "great", "amazing", "unbelieveable"];
//         var o = AL_GAME_HUA_GamePool.GamePool.Instance.get("word");
//         o.angle = Math.get_random(-15, 15);
//         this.node.addChild(o);
//         var i = t.convertToWorldSpaceAR(cc.v2(0, 0));
//         var r = this.node.convertToNodeSpaceAR(i);
//         o.setPosition(r.add(cc.v2(Math.get_random(-20, 20), -100)));
//         var a = AL_APP_SDK_MANAGER.languageManager.getLanguage();
//         var s = n[e % n.length] + "_" + ("zh" == a ? "zh" : "zh");
//         var c = o.getComponent(sp.Skeleton);
//         var l = c.setAnimation(0, s, !1);
//         c.setTrackCompleteListener(l, function () {
//             AL_GAME_HUA_GamePool.GamePool.Instance.put(o);
//         });
//     };
//     t.prototype.handle_event_click_button_setting = function () {
//         var e = this;
//         AL_GAME_HUA_Common.Common.xianshiChapingGuanggaoZhangting(function () {
//             AL_GAME_HUA_CurrencyData.CurrencyData.getInstance().tianjia_huobi({
//                 type: AL_GAME_HUA_CurrencyData.CurrencyType.COIN,
//                 num: AL_GAME_HUA_GameConst.GameConst.getInstance().reward_coin
//             });
//             AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_tishi_jiedian_mianban({
//                 str: "获得#0金币",
//                 params: [AL_GAME_HUA_GameConst.GameConst.getInstance().reward_coin.toString()]
//             });
//         });
//         AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_zhanting();
//         AL_GAME_HUA_Common.Common.xianshi_xiafang_guanggao();
//         AL_GAME_HUA_AddPrefab.AddPrefab.create_setting({
//             isGame: !0,
//             onClose: function () {
//                 ailin_sdk_manager.yincangBannerGuanggao();
//                 AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_jixu();
//             },
//             onRestart: function () {
//                 ailin_sdk_manager.yincangBannerGuanggao();
//                 AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_chongxinkaishi();
//             },
//             onHome: function () {
//                 if (
//                     AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL ||
//                     AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL
//                 ) {
//                     var t = e.popNum;
//                     var n = Math.ceil(t * AL_GAME_HUA_GameConst.GameConst.getInstance().pass_reward);
//                     var o = Math.clamp(n, 20, 500);
//                     AL_GAME_HUA_AddPrefab.AddPrefab.create_quit({
//                         star: e.starNum,
//                         coin: o,
//                         onQuit: function () {
//                             AL_GAME_HUA_Instance.Instance.Game.chuli_fanhui_zhujiemain(!0);
//                         },
//                         onContinue: function () {
//                             AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_jixu();
//                         }
//                     });
//                 } else {
//                     if (AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
//                         AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_shibai();
//                     }
//                 }
//             }
//         });
//     };
//     t.prototype.chuangjian_xingxing = function (e, t, n) {
//         var o = this;
//         var i = e.convertToWorldSpaceAR(cc.v2(0, 0));
//         var r = this.node.convertToNodeSpaceAR(i);
//         var a = this.node.convertToNodeSpaceAR(this.starIcon.convertToWorldSpaceAR(cc.v2(0, 0)));
//         var s = a.sub(r).mag() / 1200;
//         var c = AL_GAME_HUA_GamePool.GamePool.Instance.get("starIcon");
//         c.setPosition(r);
//         this.node.addChild(c);
//         cc.tween(c)
//             .to(
//                 s,
//                 {
//                     position: cc.v3(a)
//                 },
//                 {
//                     easing: "sineOut"
//                 }
//             )
//             .call(function () {
//                 AL_GAME_HUA_GamePool.GamePool.Instance.put(c);
//                 o.starIcon.stopAllActions();
//                 cc.tween(o.starIcon)
//                     .to(0.1, {
//                         scale: 1.2
//                     })
//                     .to(0.1, {
//                         scale: 1
//                     })
//                     .start();
//                 o.starNum += t;
//                 o.shuaxin_xingxing();
//                 if (n) {
//                     n();
//                 }
//             })
//             .start();
//         return c;
//     };
//     t.prototype.handle_button_callback = function (e, t) {
//         switch (t) {
//             case "setting":
//                 this.handle_event_click_button_setting();
//                 break;
//             case "debug":
//                 AL_GAME_HUA_AddPrefab.AddPrefab.xianshi_debug_mianban();
//         }
//     };
//     t.prototype.handle_toggle_callback = function (e, t) {
//         switch (t) {
//             case "theme":
//                 AL_GAME_HUA_GameData.GameData.getInstance().gameTheme = this.themeToggle.isChecked ? 0 : 1;
//                 AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_GAME_THEME_CHANGE);
//                 this.shuaxin_zhuti();
//         }
//     };
//     __decorate([w(cc.Sprite)], t.prototype, "bg", void 0);
//     __decorate([w([cc.SpriteFrame])], t.prototype, "spriteframe_bg_list", void 0);
//     __decorate([w(cc.Label)], t.prototype, "label_star", void 0);
//     __decorate([w(cc.Node)], t.prototype, "starIcon", void 0);
//     __decorate([w(cc.Node)], t.prototype, "starx2", void 0);
//     __decorate([w(cc.Label)], t.prototype, "label_time", void 0);
//     __decorate([w(cc.Node)], t.prototype, "timeIcon", void 0);
//     __decorate([w(cc.Node)], t.prototype, "comboNode", void 0);
//     __decorate([w(cc.ProgressBar)], t.prototype, "comboProgressBar", void 0);
//     __decorate([w(cc.Label)], t.prototype, "comboLabel", void 0);
//     __decorate([w(cc.Label)], t.prototype, "levelLabel", void 0);
//     __decorate([w(cc.ProgressBar)], t.prototype, "levelProgressBar", void 0);
//     __decorate([w(cc.Node)], t.prototype, "topNode", void 0);
//     __decorate([w(cc.Node)], t.prototype, "bottomNode", void 0);
//     __decorate([w([AL_GAME_HUA_PropButton.default])], t.prototype, "propButtons", void 0);
//     __decorate([w(cc.Node)], t.prototype, "enterPropLayout", void 0);
//     __decorate([w(cc.Node)], t.prototype, "timeWarnNode", void 0);
//     __decorate([w([cc.Node])], t.prototype, "winSkes", void 0);
//     __decorate([w(cc.Node)], t.prototype, "challengeNode", void 0);
//     __decorate([w(sp.Skeleton)], t.prototype, "completeSp", void 0);
//     __decorate([w(cc.Node)], t.prototype, "specialFlag", void 0);
//     __decorate([w(cc.Node)], t.prototype, "iceNode", void 0);
//     __decorate([w(AL_GAME_HUA_ToggleCustom.default)], t.prototype, "themeToggle", void 0);
//     return __decorate([S], t);
// })(AL_GAME_HUA_GameBase.default);
// exports.default = Y;

// 引入各个模块
const AL_GAME_HUA_AddPrefab = require("./AL_GAME_HUA_AddPrefab");
const AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
const AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
const AL_GAME_HUA_EventConfig = require("./AL_GAME_HUA_EventConfig");
const AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
const AL_GAME_HUA_PropConfig = require("./AL_GAME_HUA_PropConfig");
const AL_GAME_HUA_ShopConfig = require("./AL_GAME_HUA_ShopConfig");
const AL_GAME_HUA_CurrencyData = require("./AL_GAME_HUA_CurrencyData");
const AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
const AL_GAME_HUA_GameBase = require("./AL_GAME_HUA_GameBase");
const AL_GAME_HUA_GamePool = require("./AL_GAME_HUA_GamePool");
const AL_GAME_HUA_PropButton = require("./AL_GAME_HUA_PropButton");
const AL_GAME_HUA_MissionConfig = require("./AL_GAME_HUA_MissionConfig");
const AL_GAME_HUA_GoodsConfig = require("./AL_GAME_HUA_GoodsConfig");
const AL_GAME_HUA_ShopData = require("./AL_GAME_HUA_ShopData");
const AL_GAME_HUA_ToggleCustom = require("./AL_GAME_HUA_ToggleCustom");

const { ccclass, property } = cc._decorator;

/**
 * 游戏管理类
 */
@ccclass
class GameManager extends AL_GAME_HUA_GameBase.default {
    @property(cc.Sprite) bg = null;
    @property([cc.SpriteFrame]) spriteframe_bg_list = [];
    @property(cc.Label) label_star = null;
    @property(cc.Node) starIcon = null;
    @property(cc.Node) starx2 = null;
    @property(cc.Label) label_time = null;
    @property(cc.Node) timeIcon = null;
    @property(cc.Node) comboNode = null;
    @property(cc.ProgressBar) comboProgressBar = null;
    @property(cc.Label) comboLabel = null;
    @property(cc.Label) levelLabel = null;
    @property(cc.ProgressBar) levelProgressBar = null;
    @property(cc.Node) topNode = null;
    @property(cc.Node) bottomNode = null;
    @property([AL_GAME_HUA_PropButton.default]) propButtons = [];
    @property(cc.Node) enterPropLayout = null;
    @property(cc.Node) timeWarnNode = null;
    @property([cc.Node]) winSkes = [];
    @property(cc.Node) challengeNode = null;
    @property(sp.Skeleton) completeSp = null;
    @property(cc.Node) specialFlag = null;
    @property(cc.Node) iceNode = null;
    @property(AL_GAME_HUA_ToggleCustom.default) themeToggle = null;

    starNum = 0;
    popNum = 0;
    isTimeWarning = false;
    isTimeWarning2 = false;
    isTimeWarning3 = false;
    comboTween = null;
    comboCount = 0;
    _tm = Number.MAX_SAFE_INTEGER;

    onLoad() {
        AL_APP_SDK_MANAGER.on(AL_GAME_HUA_Define.GameEvent.CHANGE_SHOP_USE, this.shuaxin_beijing, this);
    }

    onDestroy() {
        AL_APP_SDK_MANAGER.off(this);
    }

    async onPreload() {
        console.log("******shuaxin_beijing");
        await this.shuaxin_beijing();
        console.log("******chushihua_ui");
        this.chushihua_ui();
    }

    async onPrepare() {
        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            await this.jiancha_shiyong_xin_pifu();
        }
        await this.bofang_jinru_donghua();
        await this.xianshi_tiaozhan_guanqia_donghua();
        await this.xianshi_jinru_prop_donghua();
    }

    chuli_youxi_kaishi() {
        this.propButtons.forEach(button => {
            button.shezhi_anniu_shifou_youxiao(true);
            ailin_sdk_manager.yincangBannerGuanggao();
        });
    }

    chuli_youxi_zhanting() {
        this.propButtons.forEach(button => {
            button.chuli_youxi_zhanting();
        });
        cc.director.getActionManager().pauseTargets([this.comboProgressBar]);
    }

    chuli_youxi_jixu() {
        this.propButtons.forEach(button => {
            button.chuli_youxi_jixu();
        });
        if (!AL_GAME_HUA_Instance.Instance.Game.isTimePause) {
            cc.director.getActionManager().resumeTargets([this.comboProgressBar]);
        }
    }

    async chuli_youxi_shengli() {
        AL_GAME_HUA_Common.Common.bofang_yinxiao("complete", this);
        await this.bofang_shengli_donghua();
        this.bofang_tuichu_donghua();
    }

    chuli_youxi_shibai() {}

    chuli_youxi_tuichu() {}

    onUpdate() {}

    chushihua_ui() {
        const gameDataInstance = AL_GAME_HUA_GameData.GameData.getInstance();
        this.starNum = 0;
        this.shuaxin_xingxing();
        const gameTheme = gameDataInstance.gameTheme;
        this.themeToggle.isChecked = gameTheme === 0;
        this.shuaxin_zhuti();

        const levelType = AL_GAME_HUA_Instance.Instance.LevelType;
        if (levelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            this.levelLabel.string = `Lv:${gameDataInstance.huoqu_yijiesuo_guanqia()}`;
        } else if (levelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
            this.levelLabel.string = `Lv:${AL_GAME_HUA_Instance.Instance.ChallengeLevel}`;
        } else if (levelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            this.levelLabel.string = `LV:${gameDataInstance.huoqu_yijiesuo_teshu_guanqia()}`;
        }

        this.levelProgressBar.progress = 0;
        this.comboProgressBar.progress = 0;
        this.comboNode.active = false;
        this.enterPropLayout.active = false;
        this.timeWarnNode.active = false;
        this.challengeNode.active = false;
        this.completeSp.node.active = false;
        this.specialFlag.active = levelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL;

        if (AL_GAME_HUA_Common.Common.shifou_keyi_kaiqi_tiaozhan_guanqia()) {
            const propConfig = AL_GAME_HUA_PropConfig.PropId;
            if (gameDataInstance.huoqu_prop_jiesuo(propConfig.REFRESH_GAME) &&
                gameDataInstance.huoqu_prop_shuliang(propConfig.REFRESH_GAME) === 0) {
                gameDataInstance.genggai_prop_shuliang(propConfig.REFRESH_GAME, 1);
            } else if (gameDataInstance.huoqu_prop_jiesuo(propConfig.TIPS_GAME) &&
                gameDataInstance.huoqu_prop_shuliang(propConfig.TIPS_GAME) === 0) {
                gameDataInstance.genggai_prop_shuliang(propConfig.TIPS_GAME, 1);
            }
        }

        const propDurations = [0.5, 0.5, 0.5, AL_GAME_HUA_GameConst.GameConst.getInstance().time_prop_duration];
        this.propButtons.forEach((button, index) => {
            button.init({
                cd: propDurations[index],
                handle_event_click: () => {
                    this.handlePropButtonClick(button);
                }
            });
            button.shezhi_anniu_shifou_youxiao(false);
        });
    }

    shuaxin_zhuti() {
        const gameTheme = AL_GAME_HUA_GameData.GameData.getInstance().gameTheme;
        this.bg.spriteFrame = this.spriteframe_bg_list[gameTheme];
    }

    async xianshi_tiaozhan_guanqia_donghua() {
        if (
            (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE &&
                AL_GAME_HUA_Instance.Instance.ChallengeLevel === 2) ||
            (AL_GAME_HUA_Common.Common.shifou_keyi_kaiqi_tiaozhan_guanqia() &&
                AL_GAME_HUA_GameConst.GameConst.getInstance().showHardTitle)
        ) {
            this.challengeNode.active = true;
            const skeleton = this.challengeNode.getChildByName("ui_nandubiaosheng").getComponent(sp.Skeleton);
            const skinLang = AL_APP_SDK_MANAGER.languageManager.getLanguage() === "zh" ? "zh" : "zh";
            skeleton.setSkin(skinLang);
            const animTrack = skeleton.setAnimation(0, "01-start", false);
            return new Promise(resolve => {
                skeleton.setTrackCompleteListener(animTrack, resolve);
            });
        } else {
            return Promise.resolve();
        }
    }

    async xianshi_wancheng_donghua() {
        this.completeSp.node.active = true;
        const animTrack = this.completeSp.setAnimation(0, "01-appear", false);
        return new Promise(resolve => {
            this.completeSp.setTrackCompleteListener(animTrack, () => {
                this.scheduleOnce(resolve, 0.5);
            });
        });
    }

    async bofang_jinru_donghua() {
        const scaleFactor = Math.min(1, cc.winSize.width / cc.view.getDesignResolutionSize().width);
        cc.tween(this.topNode)
            .to(0.28, { y: cc.winSize.height / 2 / scaleFactor }, { easing: "sineOut" })
            .start();
        cc.tween(this.bottomNode)
            .to(0.28, {
                y: (-cc.winSize.height / 2 + AL_GAME_HUA_Define.Define.Margin.bottom - this.bottomNode.height / 2) / scaleFactor
            }, { easing: "sineOut" })
            .start();
        return new Promise(resolve => {
            cc.tween(this.bottomNode).call(resolve).start();
        });
    }

    async bofang_tuichu_donghua() {
        const scaleFactor = Math.min(1, cc.winSize.width / cc.view.getDesignResolutionSize().width);
        cc.tween(this.topNode)
            .to(0.28, { y: (cc.winSize.height / 2 + this.topNode.height / 2) / scaleFactor }, { easing: "sineOut" })
            .start();
        cc.tween(this.bottomNode)
            .to(0.28, { y: (-cc.winSize.height / 2 - this.bottomNode.height / 2) / scaleFactor }, { easing: "sineOut" })
            .start();
        return new Promise(resolve => {
            cc.tween(this.bottomNode).call(resolve).start();
        });
    }

    async bofang_shengli_donghua() {
        this.winSkes.forEach(ske => {
            ske.zIndex = 1000;
            ske.active = true;
        });
        await AL_GAME_HUA_Common.Common.delay(0.67);
    }

    async jiancha_shiyong_xin_pifu() {
        if (AL_GAME_HUA_GameConst.GameConst.getInstance().skin_enabled) {
            const shopDataInstance = AL_GAME_HUA_ShopData.ShopData.getInstance();
            if (AL_GAME_HUA_GameData.GameData.getInstance().huoqu_yijiesuo_guanqia() >
                AL_GAME_HUA_GameConst.GameConst.getInstance().pop_try_skin) {
                if (shopDataInstance.trySkinCount > 0 &&
                    shopDataInstance.trySkinCount % AL_GAME_HUA_GameConst.GameConst.getInstance().pop_try_skin_count === 0) {
                    const shopConfigs = AL_GAME_HUA_ShopConfig.ShopConfig.getInstance().huoqu_suoyou_de_peizhi();
                    const availableSkins = shopConfigs.slice().filter((_, index) => shopDataInstance.huoqu_shangdian_shifou_yi_jiesuo(index) === 0);
                    if (availableSkins.length > 0) {
                        const randomSkin = availableSkins[Math.floor(Math.random() * availableSkins.length)];
                        AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_changshi_pifu_mianban({
                            skin: randomSkin,
                            onClose: () => Promise.resolve()
                        });
                        shopDataInstance.trySkinCount++;
                        return Promise.resolve();
                    }
                }
                shopDataInstance.trySkinCount++;
            }
        }
        return Promise.resolve();
    }

    shuaxin_guanqia_jindu(progress) {
        this.levelProgressBar.progress = progress;
    }

    async xianshi_jinru_prop_donghua() {
        this.enterPropLayout.active = true;
        const gameDataInstance = AL_GAME_HUA_GameData.GameData.getInstance();
        const animPromises = [];
        const timeProp = this.enterPropLayout.getChildByName("timeprop");
        const starProp = this.enterPropLayout.getChildByName("starprop");
        const magicProp = this.enterPropLayout.getChildByName("magicprop");

        if (gameDataInstance.useTimeEnter) {
            animPromises.push(this.jinru_xianshi_donghua(timeProp));
        }
        timeProp.active = gameDataInstance.useTimeEnter;

        if (gameDataInstance.useStarEnter) {
            animPromises.push(this.jinru_xianshi_donghua(starProp));
        }
        starProp.active = gameDataInstance.useStarEnter;

        if (gameDataInstance.useTipsEnter) {
            animPromises.push(this.jinru_xianshi_donghua(magicProp));
        }
        magicProp.active = gameDataInstance.useTipsEnter;

        this.enterPropLayout.getComponent(cc.Layout).updateLayout();
        this.enterPropLayout.getComponent(cc.Layout).enabled = false;
        await Promise.all(animPromises);

        if (gameDataInstance.useTimeEnter) {
            AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(AL_GAME_HUA_MissionConfig.MissionType.PROP1);
            await this.donghua_prop_1(timeProp);
            gameDataInstance.useTimeEnter = false;
        }
        if (gameDataInstance.useStarEnter) {
            AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(AL_GAME_HUA_MissionConfig.MissionType.PROP2);
            await this.donghua_prop_2(starProp);
            gameDataInstance.useStarEnter = false;
        }
        if (gameDataInstance.useTipsEnter) {
            AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(AL_GAME_HUA_MissionConfig.MissionType.PROP0);
            await this.donghua_prop_0(magicProp);
            gameDataInstance.useTipsEnter = false;
        }
        this.enterPropLayout.active = false;
    }

    async donghua_prop_0(propNode) {
        const skeleton = propNode.children[0].getComponent(sp.Skeleton);
        skeleton.setAnimation(0, "idle", true);
        AL_GAME_HUA_Common.Common.bofang_yinxiao("mofabang", this);

        return new Promise(resolve => {
            skeleton.scheduleOnce(async () => {
                for (let i = 0; i < 4; i++) {
                    await AL_GAME_HUA_Instance.Instance.Game.stage.chuli_tishi_luoji();
                }
                cc.tween(propNode)
                    .to(0.25, { scale: 0, opacity: 0 })
                    .call(() => propNode.destroy())
                    .start();
                resolve();
            }, 0.5);
        });
    }

    async donghua_prop_1(propNode) {
        const startPosition = propNode.getPosition();
        const targetPosition = propNode.parent.convertToNodeSpaceAR(this.timeIcon.convertToWorldSpaceAR(cc.v2(0, 0)));
        const randomOffset = Math.random() * 400 - 200;
        const controlPoint = cc.v2((startPosition.x + targetPosition.x) / 2 + randomOffset, (startPosition.y + targetPosition.y) / 2);

        cc.tween(propNode).to(1, { scale: 0.5 }).start();
        cc.tween(propNode)
            .bezierTo(2 / 3, controlPoint, controlPoint, targetPosition)
            .call(() => {
                this.chuangjian_prop_texiao(this.timeIcon);
                AL_GAME_HUA_Instance.Instance.Game.totalTime += 60;
                this.shuaxin_shijian(AL_GAME_HUA_Instance.Instance.Game.totalTime);
                propNode.destroy();
                AL_GAME_HUA_Common.Common.bofang_yinxiao("Progress", this);
            })
            .start();
    }

    async donghua_prop_2(propNode) {
        const startPosition = propNode.getPosition();
        const targetPosition = propNode.parent.convertToNodeSpaceAR(this.starIcon.convertToWorldSpaceAR(cc.v2(0, 0)));
        const randomOffset = Math.random() * 400 - 200;
        const controlPoint = cc.v2((startPosition.x + targetPosition.x) / 2 + randomOffset, (startPosition.y + targetPosition.y) / 2);

        cc.tween(propNode).to(1, { scale: 0.5 }).start();
        cc.tween(propNode)
            .bezierTo(2 / 3, controlPoint, controlPoint, targetPosition)
            .call(() => {
                this.starIcon.opacity = 0;
                this.starx2.active = true;
                this.chuangjian_prop_texiao(this.starIcon);
                AL_GAME_HUA_Common.Common.bofang_yinxiao("Progress", this);
                propNode.destroy();
            })
            .start();
    }

    chuangjian_prop_texiao(targetNode) {
        const effectNode = AL_GAME_HUA_GamePool.GamePool.Instance.get("crashEffect");
        effectNode.parent = targetNode;
        const skeleton = effectNode.children[0].getComponent(sp.Skeleton);
        const animation = skeleton.setAnimation(0, "show", false);

        skeleton.setTrackCompleteListener(animation, () => {
            AL_GAME_HUA_GamePool.GamePool.Instance.put(effectNode);
        });
        effectNode.setPosition(cc.v2());

        return effectNode;
    }

    jinru_xianshi_donghua(propNode) {
        propNode.active = true;
        propNode.scale = 0;
        propNode.opacity = 0;
        return new Promise(resolve => {
            cc.tween(propNode)
                .to(0.2, { scale: 1, opacity: 255 }, { easing: "backOut" })
                .call(resolve)
                .start();
        });
    }

    shuaxin_xingxing() {
        this.label_star.string = this.starNum.toString();
    }

    async shuaxin_beijing() {
        const shopUse = AL_GAME_HUA_ShopData.ShopData.getInstance().huoqu_shangdian_shifou_zhengzai_shiyong();
        const bgSpriteFrame = await AL_GAME_HUA_ShopConfig.ShopConfig.getInstance().jiazai_beijing_pifu(shopUse);

        this.bg.spriteFrame = bgSpriteFrame;
        this.bg.addAutoReleaseAssets(bgSpriteFrame);
    }

/**
 * 刷新时间
 * 根据传入的时间参数调整UI标签的显示及相关动画效果
 * @param {number} elapsedTime - 传入的时间参数
 */
shuaxin_shijian(elapsedTime) {
    // 将时间向下取整
    const roundedTime = Math.floor(elapsedTime);

    // 检查时间是否小于第一个警告时间
    const isFirstWarning = roundedTime < AL_GAME_HUA_GameConst.GameConst.getInstance().warnning_time1;
    if (this.isTimeWarning !== isFirstWarning) {
        this.isTimeWarning = isFirstWarning;
        this.label_time.node.color = isFirstWarning ? cc.color().fromHEX("#F93206") : cc.color().fromHEX("#FFFFFF");

        if (isFirstWarning) {
            this.timeIcon.stopAllActions();
            cc.tween(this.timeIcon)
                .to(0.3, { scale: 1.05 })
                .to(0.3, { scale: 0.95 })
                .union()
                .repeatForever()
                .start();
        } else {
            this.timeIcon.stopAllActions();
            this.timeIcon.scale = 1;
        }
    }

    // 检查时间是否小于第二个警告时间
    const isSecondWarning = roundedTime < AL_GAME_HUA_GameConst.GameConst.getInstance().warnning_time2;
    if (this.isTimeWarning2 !== isSecondWarning) {
        this.isTimeWarning2 = isSecondWarning;
    }

    // 检查时间是否小于第三个警告时间
    const isThirdWarning = roundedTime < AL_GAME_HUA_GameConst.GameConst.getInstance().warnning_time3;
    if (this.isTimeWarning3 !== isThirdWarning) {
        this.isTimeWarning3 = isThirdWarning;
        isThirdWarning ? this.xianshi_shijian_jinggao() : this.yincang_shijian_jinggao();
    }

    // 如果在第三个警告时间内并且时间发生变化，播放声音
    if (isThirdWarning && this._tm !== roundedTime) {
        this._tm = roundedTime;
        AL_GAME_HUA_Common.Common.bofang_yinxiao("timer", this);
    }

    // 格式化时间并更新UI标签的字符串显示
    const formattedTime = AL_GAME_HUA_Common.Common.geshihua_shijian(Math.max(0, 1000 * elapsedTime));
    if (formattedTime !== this.label_time.string) {
        this.label_time.string = formattedTime;
    }
}

    xianshi_shijian_jinggao() {
        this.timeWarnNode.active = true;
        this.timeWarnNode.opacity = 0;
        this.timeWarnNode.stopAllActions();
        cc.tween(this.timeWarnNode)
            .to(0.3, { opacity: 255 })
            .to(0.7, { opacity: 100 })
            .union()
            .repeatForever()
            .start();
    }

    yincang_shijian_jinggao() {
        this.timeWarnNode.stopAllActions();
        cc.tween(this.timeWarnNode)
            .to(1, { opacity: 0 })
            .call(() => {
                this.timeWarnNode.active = false;
            })
            .start();
    }

    handle_event_click_button_tips() {
        AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
            source: AL_GAME_HUA_EventConfig.AssetsSource.game,
            action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
            goodsList: [{
                goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_prompt,
                num: 1
            }]
        });
        AL_GAME_HUA_Instance.Instance.Game.stage.chuli_tishi_luoji();
    }

    handle_event_click_button_refresh() {
        AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
            source: AL_GAME_HUA_EventConfig.AssetsSource.game,
            action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
            goodsList: [{
                goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_reset,
                num: 1
            }]
        });
        AL_GAME_HUA_Instance.Instance.Game.stage.shuaxin_daoju_he_yuansu_zhuangtai();
    }

    handle_event_click_button_change() {
        AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
            source: AL_GAME_HUA_EventConfig.AssetsSource.game,
            action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
            goodsList: [{
                goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_brush,
                num: 1
            }]
        });
        AL_GAME_HUA_Instance.Instance.Game.stage.daoju_qihuan();
    }

    handle_event_click_button_time() {
        AL_GAME_HUA_EventConfig.EventConfig.getInstance().assetsReportCost({
            source: AL_GAME_HUA_EventConfig.AssetsSource.game,
            action: AL_GAME_HUA_EventConfig.AssetsAction.cost,
            goodsList: [{
                goods: AL_GAME_HUA_GoodsConfig.GoodsId.prop_freeze,
                num: 1
            }]
        });
        AL_GAME_HUA_Instance.Instance.Game.stage.shijian_daoju_xiaoguo_luoji();
    }

    xianshi_combo(comboPosition) {
        const comboCount = ++this.comboCount;
        this.comboNode.active = true;
        this.comboProgressBar.progress = 1;
        this.comboLabel.string = comboCount.toString();

        if (this.comboTween) {
            this.comboTween.stop();
        }

        const duration = Math.max(3, 10 - 0.5 * comboCount);
        this.comboTween = cc.tween(this.comboProgressBar)
            .to(duration, { progress: 0 })
            .call(() => {
                this.comboNode.active = false;
                this.comboProgressBar.progress = 0;
                this.comboCount = 0;
                this.comboTween = null;
            })
            .start();

        if (AL_GAME_HUA_Instance.Instance.Game.isTimePause) {
            this.zhanting_combo();
        }

        const sfx = comboCount >= 4 ? "stars05" : `stars0${comboCount}`;
        AL_GAME_HUA_Common.Common.bofang_yinxiao(sfx, this);

        if (comboCount >= 3) {
            this.xianshi_word(comboCount - 3, comboPosition);
        }
    }

    zhanting_combo() {
        cc.director.getActionManager().pauseTargets([this.comboProgressBar]);
    }

    jixu_combo() {
        cc.director.getActionManager().resumeTargets([this.comboProgressBar]);
    }

    xianshi_word(index, positionNode) {
        const phrases = ["cool", "good", "pretty", "great", "amazing", "unbelieveable"];
        const wordNode = AL_GAME_HUA_GamePool.GamePool.Instance.get("word");

        wordNode.angle = Math.random() * 30 - 15;
        this.node.addChild(wordNode);

        const worldPosition = positionNode.convertToWorldSpaceAR(cc.v2(0, 0));
        const localPosition = this.node.convertToNodeSpaceAR(worldPosition);
        wordNode.setPosition(localPosition.add(cc.v2(Math.random() * 40 - 20, -100)));

        const language = AL_APP_SDK_MANAGER.languageManager.getLanguage();
        const phrase = phrases[index % phrases.length] + (language === "zh" ? "_zh" : "_en");
        const skeletonComponent = wordNode.getComponent(sp.Skeleton);

        const animTrack = skeletonComponent.setAnimation(0, phrase, false);
        skeletonComponent.setTrackCompleteListener(animTrack, () => {
            AL_GAME_HUA_GamePool.GamePool.Instance.put(wordNode);
        });
    }

    handle_event_click_button_setting() {
        AL_GAME_HUA_Common.Common.xianshiChapingGuanggaoZhangting(() => {
            AL_GAME_HUA_CurrencyData.CurrencyData.getInstance().tianjia_huobi({
                type: AL_GAME_HUA_CurrencyData.CurrencyType.COIN,
                num: AL_GAME_HUA_GameConst.GameConst.getInstance().reward_coin
            });
            AL_GAME_HUA_AddPrefab.AddPrefab.chuangjian_tishi_jiedian_mianban({
                str: "获得#0金币",
                params: [AL_GAME_HUA_GameConst.GameConst.getInstance().reward_coin.toString()]
            });
        });

        AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_zhanting();
        AL_GAME_HUA_Common.Common.xianshi_xiafang_guanggao();

        AL_GAME_HUA_AddPrefab.AddPrefab.create_setting({
            isGame: true,
            onClose: () => {
                ailin_sdk_manager.yincangBannerGuanggao();
                AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_jixu();
            },
            onRestart: () => {
                ailin_sdk_manager.yincangBannerGuanggao();
                AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_chongxinkaishi();
            },
            onHome: () => {
                const levelType = AL_GAME_HUA_Instance.Instance.LevelType;

                if (levelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL ||
                    levelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
                    const currentPopNum = this.popNum;
                    const rewardLimit = AL_GAME_HUA_GameConst.GameConst.getInstance().pass_reward;
                    const coins = Math.clamp(Math.ceil(currentPopNum * rewardLimit), 20, 500);

                    AL_GAME_HUA_AddPrefab.AddPrefab.create_quit({
                        star: this.starNum,
                        coin: coins,
                        onQuit: () => AL_GAME_HUA_Instance.Instance.Game.chuli_fanhui_zhujiemain(true),
                        onContinue: () => AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_jixu()
                    });
                } else if (levelType === AL_GAME_HUA_Define.Define.LevelType.CHALLENGE) {
                    AL_GAME_HUA_Instance.Instance.Game.chuli_youxi_shibai();
                }
            }
        });
    }

    chuangjian_xingxing(sourceNode, value, callback) {
        const startWorldPos = sourceNode.convertToWorldSpaceAR(cc.v2(0, 0));
        const startLocalPos = this.node.convertToNodeSpaceAR(startWorldPos);
        const endLocalPos = this.node.convertToNodeSpaceAR(this.starIcon.convertToWorldSpaceAR(cc.v2(0, 0)));
        const travelTime = endLocalPos.sub(startLocalPos).mag() / 1200;

        const starIcon = AL_GAME_HUA_GamePool.GamePool.Instance.get("starIcon");
        starIcon.setPosition(startLocalPos);
        this.node.addChild(starIcon);

        cc.tween(starIcon)
            .to(travelTime, { position: cc.v3(endLocalPos) }, { easing: "sineOut" })
            .call(() => {
                AL_GAME_HUA_GamePool.GamePool.Instance.put(starIcon);
                this.starIcon.stopAllActions();
                cc.tween(this.starIcon)
                    .to(0.1, { scale: 1.2 })
                    .to(0.1, { scale: 1 })
                    .start();

                this.starNum += value;
                this.shuaxin_xingxing();

                if (callback) {
                    callback();
                }
            })
            .start();

        return starIcon;
    }

    handle_button_callback(event, type) {
        if (type === "setting") {
            this.handle_event_click_button_setting();
        } else if (type === "debug") {
            AL_GAME_HUA_AddPrefab.AddPrefab.xianshi_debug_mianban();
        }
    }

    handle_toggle_callback(event, type) {
        if (type === "theme") {
            AL_GAME_HUA_GameData.GameData.getInstance().gameTheme = this.themeToggle.isChecked ? 0 : 1;
            AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_GAME_THEME_CHANGE);
            this.shuaxin_zhuti();
        }
    }

    handlePropButtonClick(button) {
        switch (button.type) {
            case AL_GAME_HUA_PropConfig.PropId.TIME_GAME:
                this.handle_event_click_button_time();
                AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                    AL_GAME_HUA_MissionConfig.MissionType.PROP6
                );
                break;
            case AL_GAME_HUA_PropConfig.PropId.CHANGE_GAME:
                this.handle_event_click_button_change();
                AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                    AL_GAME_HUA_MissionConfig.MissionType.PROP5
                );
                break;
            case AL_GAME_HUA_PropConfig.PropId.REFRESH_GAME:
                this.handle_event_click_button_refresh();
                AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                    AL_GAME_HUA_MissionConfig.MissionType.PROP4
                );
                break;
            case AL_GAME_HUA_PropConfig.PropId.TIPS_GAME:
                this.handle_event_click_button_tips();
                AL_GAME_HUA_MissionConfig.MissionConfig.getInstance().tianjia_renwu_shuliang_by_leixing(
                    AL_GAME_HUA_MissionConfig.MissionType.PROP3
                );
                break;
            default:
                break;
        }
    }
}

module.exports = GameManager;

